package atom.core0.app.thread.manager;

import java.util.ArrayList;
import java.util.List;

import atom.core0.app.thread.daemon.BaseDaemonThread;

public class DaemonThreadManager
{
	private static List<BaseDaemonThread>	threadList	= new ArrayList();

	public static List<BaseDaemonThread> getThreadList()
    {
    	return threadList;
    }
	public static void start(BaseDaemonThread thread)
	{
		thread.start();
		threadList.add(thread);

	}

	public static void interrupt()
	{
		for (int i = 0; i < threadList.size(); i++)
		{
			BaseDaemonThread thread = threadList.get(i);
			thread.interrupt();
		}
	}
	public static void interrupt(BaseDaemonThread thread)
	{
		for (int i = 0; i < threadList.size(); i++)
		{
			BaseDaemonThread t1 = threadList.get(i);
			if (t1==thread)
			{
				//threadList.remove(thread);
				thread.interrupt();
				break;
			}
		}
	}	
	synchronized public static void remove(BaseDaemonThread thread)
	{
		threadList.remove(thread);
	}	
}
